const bcrypt = require('bcrypt');

// 加密
var encrypt = (pwd) => {
    var salt = bcrypt.genSaltSync(10)
    // 对明文加密
    var hash = bcrypt.hashSync(pwd, salt)
    return hash
}

// 解密
var decode = (pwd1, pwd2) => {
    var isOk = bcrypt.compareSync(pwd1, pwd2)
    return isOk
}

module.exports={
    encrypt,decode
}